/**
 * Created by suweiming on 2017/12/30.
 */
import React from 'react';
import {StyleSheet, Text, View, TextInput, Image} from 'react-native';
import {Form} from '../css/form';
import {Button} from 'native-base';
import {get, post,domain} from '../lib/http';

export default class Login extends React.Component {

    render() {
        console.log(JSON.stringify(Form.input));
        return (
            <View style={CSS.container}>
                <View style={CSS.img}>
                    <Text>LOGIN</Text>
                </View>
                <View style={CSS.login}>
                    <View style={CSS.ctner}>
                        <TextInput placeholder="手机号" defaultValue="admin" style={Form.input}/>
                    </View>
                    <View style={CSS.ctner}>
                        <TextInput secureTextEntry={true} defaultValue="123456"  placeholder="密码" style={Form.input}/>
                    </View>
                    <View style={CSS.code}>
                        <TextInput value="211064"  placeholder="图片验证码" style={Form.input}/>
                        <Image
                            style={{width: 100, height: 40}}
                            source={{uri: domain+'/api/admin/code/captcha-image'}}
                        />
                    </View>
                    <View style={CSS.ctner}>
                        <Button
                            style={Form.btn}
                            title="登录" onPress={() => {
                            // alert(JSON.stringify({userName: 'admin', password: '123456'}));
                            this.props.login({userName: 'admin', password: '123456',imgCode:'211064'});
                            // navigate('home', { name: 'Jane' });
                            // post('user/login', {userName: 'admin', password: '123456',imgCode:'211064'})
                        }}><Text>登录</Text></Button>
                    </View>
                </View>
            </View>
        );
    }
}
export const CSS = StyleSheet.create({
    img: {flex: 1},
    login: {flex:1},
    code:{marginTop: 20,flexDirection:'row',},
    ctner: {marginTop: 20},
    container: {
        flex: 1,
        marginTop: 0,
        padding: 20,
    }
});

